home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / Source / MSG Demo 1.4.source Folder / Demo ƒ / Fades ƒ / Pour scroll fade.c < prev    next >
Text File  |  1994-04-19  |  3KB  |  111 lines

  1. /**********************************************************************\
  2.  
  3. File:        Pour scroll fade.c
  4.  
  5. Purpose:    Graphic effect to fade main window to solid pattern.
  6.             See comments below for more description.
  7.  
  8. This program is free software; you can redistribute it and/or modify
  9. it under the terms of the GNU General Public License as published by
  10. the Free Software Foundation; either version 2 of the License, or
  11. (at your option) any later version.
  12.  
  13. This program is distributed in the hope that it will be useful,
  14. but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16. GNU General Public License for more details.
  17.  
  18. You should have received a copy of the GNU General Public License
  19. along with this program in a file named "GNU General Public License".
  20. If not, write to the Free Software Foundation, 675 Mass Ave,
  21. Cambridge, MA 02139, USA.
  22.  
  23. \**********************************************************************/
  24.  
  25. #include "timing.h"
  26.  
  27. #define CorrectTime 2
  28. #define theWindowHeight (boundsRect.bottom-boundsRect.top)
  29. #define theWindowWidth (boundsRect.right-boundsRect.left)
  30.  
  31. pascal short PourScrollFade(Rect boundsRect, Pattern *thePattern);
  32.  
  33. /* Scroll down in tiny strips, starting at the left and moving right.  Scroll
  34.    strips 1-(N), then strips 1-(N+1), etc.  When strip 1 is done, don't do it
  35.    anymore!  (Duh, but this was difficult to get right.)  So only scroll strips
  36.    2-(N), and so on. */
  37.    
  38. pascal short PourScrollFade(Rect boundsRect, Pattern *thePattern)
  39. {
  40.     Rect            *dest;
  41.     int                *iter;
  42.     Rect            scrollsource;
  43.     int                i;
  44.     int                startstrip,endstrip;
  45.     int                ScrollSize, BoxSize;
  46.     long            temp;
  47.     int                NumStrips;
  48.     
  49.     NumStrips=theWindowWidth/4;
  50.     dest=(Rect*)NewPtr(sizeof(Rect)*NumStrips);
  51.     if (dest==0L)
  52.         return -1;        /* memory error */
  53.     iter=(int*)NewPtr(sizeof(int)*NumStrips);
  54.     if (iter==0L)
  55.     {
  56.         DisposePtr(dest);
  57.         return -1;        /* memory error */
  58.     }
  59.     
  60.     ScrollSize=theWindowHeight/50;
  61.     BoxSize=theWindowWidth/NumStrips;
  62.     
  63.     SetRect(&scrollsource, boundsRect.left, boundsRect.top, boundsRect.left+BoxSize,
  64.         boundsRect.bottom);
  65.         
  66.     for (i=0; i<NumStrips; i++)
  67.     {
  68.         dest[i].top = 0;
  69.         dest[i].bottom=ScrollSize;
  70.         dest[i].left=i*BoxSize;
  71.         dest[i].right=dest[i].left+BoxSize;
  72.         OffsetRect(&(dest[i]), boundsRect.left, boundsRect.top);
  73.         
  74.         iter[i]=theWindowHeight;
  75.     }
  76.     
  77.     startstrip=0;
  78.     endstrip=1;
  79.     do
  80.     {
  81.         StartTiming();
  82.         
  83.         ScrollTheRect(&scrollsource, 0, ScrollSize, 0L);
  84.         
  85.         for (i=startstrip; i<endstrip; i++)
  86.         {
  87.             FillRect(&dest[i], *thePattern);
  88.             iter[i]-=ScrollSize;
  89.         }
  90.         
  91.         if (endstrip<NumStrips)
  92.         {
  93.             endstrip++;
  94.             scrollsource.right+=BoxSize;
  95.         }
  96.         if (iter[startstrip]<=0)
  97.         {
  98.             startstrip++;
  99.             scrollsource.left+=BoxSize;
  100.         }
  101.         
  102.         TimeCorrection(CorrectTime);
  103.     }
  104.     while (startstrip<endstrip);
  105.     
  106.     DisposePtr(dest);
  107.     DisposePtr(iter);
  108.     
  109.     return 0;
  110. }
  111.